package BeenChina.PM.Service;

 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ServiceFactory {

 private ServiceFactory(){}
 
 private static final ServiceFactory instance = new ServiceFactory();
 
 public static ServiceFactory getInstance()
 {
	 return instance;
 }

	private BaseInfoService baseInfoService =null;
	private CommonInfoService commonInfoService = null;
	private CaseInfoService caseInfoService = null;
	private CaseProductionInfoService caseProductionInfoService =null;
	private SystemInfoService systemInfoService = null;
	private QualityInfoService qualityInfoService = null;
	
	
	public QualityInfoService getQualityInfoService()
	{
		if (qualityInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			qualityInfoService = (QualityInfoService)context.getBean("QualityInfoService");
		 
		}
		 return qualityInfoService;
	}
	
	
	public BaseInfoService getBaseInfoService()
	{
		if (baseInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			baseInfoService = (BaseInfoService)context.getBean("BaseInfoService");
		 
		}
		 return baseInfoService;
	}
	
	public CommonInfoService getCommonInfoService()
	{
		if (commonInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			commonInfoService =(CommonInfoService)context.getBean("CommonInfoService");
		}
		 return commonInfoService;
	}
	
	public CaseInfoService getCaseInfoService()
	{
		if (caseInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			caseInfoService =(CaseInfoService)context.getBean("CaseInfoService");
		}
		 return caseInfoService;
	}
	

	public CaseProductionInfoService getCaseProductionInfoService()
	{
		if (caseProductionInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			caseProductionInfoService =(CaseProductionInfoService)context.getBean("CaseProductionInfoService");
		}
		 return caseProductionInfoService;
	}
	
	public SystemInfoService getSystemInfoService()
	{
		if (systemInfoService==null){
			ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
			systemInfoService =(SystemInfoService)context.getBean("SystemInfoService");
		}
		 return systemInfoService;
	}
}
